<#include "ftls/spring.ftl"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Pragma" content="no-cache"></meta>
<meta http-equiv="Cache-Control" content="no-cache"></meta>
<meta http-equiv="Expires" content="0"></meta>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><@message "title"/></title>
<script type="text/javascript" src="static/plugins/jquery/jquery-1.8.3.min.js"></script>
<!-- <script type="text/javascript" src="static/jmax/js/common.js"></script> -->
<link rel="shortcut icon" href="static/jmax/images/favicon.png">
<style>
	body {
	  margin: 0px;
	  padding: 0px;
	  height: 100%;
	  width: 100%;
	  min-width: 1000px;
	}
	.loginTop {
		 height: 80px;
	}
	.loginMiddel {
	   background-color: #FFFFFF;
	   background-image: url(static/jmax/images/login_bg.jpg);
	   background-repeat: repeat-x;
	   background-position: center center;
	   height: 400px;
	}
	.loginBottom {
		 height: 120px;
	}
	div#loginWin {
		position: absolute;  
		height: 130px; 
		width: 380px;
		left:50%;  
  		top:50%;  
		margin-left:-190px;  
 		margin-top:-65px;  
		background: transparent url("static/jmax/images/loginLogobd.png") repeat scroll 0% 0%;
	}
	
	.titleLogin {
		color: rgb(170, 10, 152);
	}
</style>
</head>
<body style="text-align: center;">
	<div class="loginTop">
	
	</div>
	<div class="loginMiddel">
		<div>
			<a href="portal.action?index" target="_blank" class="titleLogin">进入jmax论坛</a>
			<h3 style="color: red;">为了演示，初始化数据请不要删除或移除！</h3>
		</div>
		<div id="loginWin">
			<form id="loginForm" method="post">
				<input type="hidden" id="remember" name="isRemember" value="false"/>
				<table>
					<tr>
						<td colspan="3">
							<b class="titleLogin"><@message "title"/>登录</b>
						</td>
					</tr>
					<tr>
						<td width="60px">
							<label style="font-size: 14px;color:white;">帐号:</label> 
						</td>
						<td colspan="2">
							<input type="text" name="loginName" placeholder="LoginName" style="width: 260px;height: 20px;" value="root"></input>
						</td>
					</tr>
					<tr>
						<td>
							<label style="font-size: 14px;color:white;">密码:</label> 
						</td>
						<td colspan="2">
							<input type="password" placeholder="Password" name="password" style="width: 260px;height: 20px;" value="root"></input>
						</td>
					</tr>
					<tr>
						<td>
							
						</td>
						<td width="75px">
							<a href="javascript:void(0)" onclick="login()" style="text-decoration: none;color:rgb(25, 240, 232);"><b>登录</b></a> 
						</td>
						<td width="75px">
							<a href="javascript:void(0)" onclick="cleardata()" style="text-decoration: none;color:rgb(25, 240, 232);"><b>重置</b></a>
						</td>
					</tr>
					<tr>
						<td colspan="3">
							<div style="padding: 5px 0; text-align: center; color: red;"><b id="showError"></b></div>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	
	<div class="loginBottom">
	</div>
	
	<script type="text/javascript">
	document.onkeydown = function(e) {
		var event = e || window.event;
		var code = event.keyCode || event.which || event.charCode;
		if (code == 13) {
			login();
		}
	}
	
	$(function() {
		$("input[name='loginName']").focus();
		//发送访问统计
		$.post("pageView.action?pageViewCount",{formPage:"LOGINPAGE"},function(result){
		    console.log('统计返回：'+result);
		});
// 		console.log(document.body.clientHeight);
	});
	
	function cleardata() {
		$("input[name='loginName']").val("");
		$("input[name='password']").val("");
		$("input[name='loginName']").focus();
	}
	
	function login() {
		if ($("input[name='loginName']").val() == "") {
			showError("帐号不能为空，请输入");
			$("input[name='loginName']").focus();
			return;
		} 
		if($("input[name='password']").val() == "") {
			showError("密码不能为空，请输入");
			$("input[name='password']").focus();
			return;
		}
		
		//ajax异步提交  
		$.ajax({
			type : "POST",
			url : "authLogin.action?login",
			data : $("#loginForm").serialize(), //序列化               
			error : function(request) { // 设置表单提交出错 
				printLog(request);
				showError('登陆错误'); //登录错误提示信息
			},
			success : function(data) {
				var d = $.parseJSON(data);
				if (d.success) {
					window.location.href='main.do?main';
				} else {
					showError(d.msg)
				}
				
			}
		});
	}
	
	function showError(msg) {
		$("#showError").html(msg);
	}
	</script>
	
	
	
	
</body>
</html>